package customfields;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class TextBoxField extends VerticalFieldManager {
	private int managerWidth;
	private int managerHeight;
	private EditField editField;

	public TextBoxField(int width, int height, long style) {
		super(Manager.NO_VERTICAL_SCROLL | style);
		managerWidth = width;
		managerHeight = height;
		VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL);
		add(vfm);
	}

	public void paint(Graphics g) {
		super.paint(g);
		g.setColor(Color.GRAY);
		g.drawRect(0, 0, getWidth(), getHeight());
	}

	public void sublayout(int width, int height) {
		if (managerWidth == 0) {
			managerWidth = width;
		}
		if (managerHeight == 0) {
			managerHeight = height;
		}
		super.sublayout(managerWidth, managerHeight);
		setExtent(managerWidth,managerHeight);
	}


	public String getText() {
		return editField.getText();
	}

	public void setText(String text) {
		editField.setText(text);
	}
}